Skip to content

[Core] Add FlashTransfer Logic, Fix Aot and mac sending image issue#58

Closed
Lilyltt wants to merge 4 commits into
LagrangeDev:mainfrom
Lilyltt:main
Closed

[Core] Add FlashTransfer Logic, Fix Aot and mac sending image issue#58
Lilyltt wants to merge 4 commits into
LagrangeDev:mainfrom
Lilyltt:main

Conversation

@Lilyltt
Copy link
Copy Markdown
Contributor

@Lilyltt Lilyltt commented Sep 11, 2025

No description provided.

Copilot AI review requested due to automatic review settings September 11, 2025 10:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds FlashTransfer upload logic as an alternative to Highway upload for AOT (Ahead-of-Time) compiled environments and macOS platforms, while fixing image sending issues on these platforms.

  • Implements FlashTransfer upload mechanism with chunked file uploading
  • Adds platform-specific logic to choose between Highway and FlashTransfer upload methods
  • Creates supporting protobuf message structures for FlashTransfer communication

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Lagrange.Core/Message/Entities/ImageEntity.cs Adds platform detection to conditionally use FlashTransfer or Highway upload
Lagrange.Core/Internal/Packets/Service/FlashTransferUploadResp.cs Defines response structure for FlashTransfer upload operations
Lagrange.Core/Internal/Packets/Service/FlashTransferUploadReq.cs Defines request structures for FlashTransfer upload with chunking support
Lagrange.Core/Internal/Context/FlashTransferContext.cs Implements the complete FlashTransfer upload logic with chunked file handling
Lagrange.Core/BotContext.cs Integrates FlashTransferContext into the bot context

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Lagrange.Core/Internal/Context/FlashTransferContext.cs Outdated
}
}

// cnm闹禅tx为什么不能并发,回答我
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment contains inappropriate language and should be replaced with a professional technical comment explaining why sequential processing is required instead of concurrent uploads.

Suggested change
// cnm闹禅tx为什么不能并发,回答我
// Sequential processing is required because the server expects chunks to be uploaded in order. Concurrent uploads may cause data integrity issues or protocol violations.

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +55
if (RuntimeFeature.IsDynamicCodeCompiled || !RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext));
}
else
{
await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value);
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition logic appears inverted. It should check for AOT compilation (!IsDynamicCodeCompiled) OR macOS platform to use FlashTransfer, not the opposite.

Suggested change
if (RuntimeFeature.IsDynamicCodeCompiled || !RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext));
}
else
{
await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value);
if (!RuntimeFeature.IsDynamicCodeCompiled || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
await context.FlashTransferContext.UploadFile(result.Ext.UKey, Stream.Value);
}
else
{
await context.HighwayContext.UploadFile(Stream.Value, message.IsGroup() ? 1004 : 1003, ProtoHelper.Serialize(result.Ext));

Copilot uses AI. Check for mistakes.
Lilyltt and others added 3 commits September 11, 2025 18:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: sisi0318 <sisi0318@users.noreply.github.com
@Lilyltt Lilyltt closed this Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants